package com.ymatou.iapi.dglogin.testcase;

import java.util.List;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.member.parameter.CreateMemberBean;
import com.ymatou.iapi.dglogin.parameter.BindMobileWithWeiXinBean;
import com.ymatou.iapi.dglogin.parameter.UserWxInfo;
import com.ymatou.iapi.dglogin.parameter.WxGetPhoneNumber;
import com.ymatou.iapi.dglogin.parameter.WxLoginSession;
import com.ymatou.iapi.dglogin.service.BindMobileWithWeiXinCall;
import com.ymatou.iapi.dguser.parameter.UserCreateBean;
import com.ymatou.mq.admin.parameter.MessageListBean;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.DGUserCallService;
import com.ymttest.business.service.GodMemberService;
import com.ymttest.business.service.MqQueryCallService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.sqlwapper.DGUserWapper;
import com.ymttest.utils.TestDataManager;
/**
*买家微信绑定手机号
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_BindMobileWithWeiXin{
	private static BindMobileWithWeiXinBean bindmobilewithweixinBean;
	private static BindMobileWithWeiXinCall bindmobilewithweixinCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("买家微信绑定手机号");
	}

	@Before
	public void caseUp() {
		bindmobilewithweixinBean=new BindMobileWithWeiXinBean();
		bindmobilewithweixinCall=new BindMobileWithWeiXinCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(bindmobilewithweixinCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_BindMobileWithWeiXin_001() {
		Logger.start(true,"买家微信绑定手机号成功");
		try {
			UserCreateBean u = DGUserCallService.initUsercreateBean();
			int userId = DGUserCallService.UserCreateCall(u);
			Integer shopId = GodmchManageCallService.CreateSellerMch();
			CreateMemberBean createMem = GodMemberService.initCreateMemberBean(shopId,userId,u.getOpenId());
			GodMemberService.creatememberCall(createMem);
			
			String mobile=TestDataManager.getPhoneNum();
			//新用户授权联登 等于注册
			bindmobilewithweixinBean.setIv(TestDataManager.getUTF8Base64(DGUserCallService.IV));
//			wxauthloginBean.setIv(DGUserCallService.IV);
			WxLoginSession wxLoginSession=new WxLoginSession();
			wxLoginSession.setOpenId(u.getOpenId());
			wxLoginSession.setSessionKey(TestDataManager.getUTF8Base64(DGUserCallService.SESSIONKEY));
			wxLoginSession.setUnionId(u.getUnionId());
			String loginSession = DGUserCallService.encryptWxLoginSession(wxLoginSession);
			bindmobilewithweixinBean.setLoginSession(loginSession);
			//加密组装encryptedData
			WxGetPhoneNumber WxGetPhoneNumber=new WxGetPhoneNumber();
			WxGetPhoneNumber.setCountryCode("86");
			WxGetPhoneNumber.setPhoneNumber("86"+mobile);
			WxGetPhoneNumber.setPurePhoneNumber(mobile);
			String encryptedData=DGUserCallService.encryptWxEncryptedData(FormatUtil.beanToGSONString(WxGetPhoneNumber), DGUserCallService.IV, DGUserCallService.SESSIONKEY);

			bindmobilewithweixinBean.setEncryptedData(encryptedData);
			bindmobilewithweixinBean.setShopId(shopId);
			bindmobilewithweixinBean.setUserId(userId);
			bindmobilewithweixinCall.setData(bindmobilewithweixinBean);
			bindmobilewithweixinCall.callService();			
			Logger.verifyEquals("true", bindmobilewithweixinCall.getString("success"), "验证success");
			//20200526 现在直接调用不绑定
//			MessageListBean MessageListBean = MqQueryCallService.initGoduserBindMobile(userId);
//			List <Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
//			if(joa.size()==0){
//				Thread.sleep(5000);
//				 joa = MqQueryCallService.GetMqMessage(MessageListBean);
//			}
//			joa.forEach(ele->{
//				Logger.debug(ele.toString());
//			});
//			Logger.verifyEquals(WxGetPhoneNumber.getPhoneNumber(), joa.get(0).get("mobile"), "验证mobile");
//			Logger.verifyEquals(userId, joa.get(0).get("userId"), "验证userId");
//			Logger.verifyEquals(shopId, joa.get(0).get("shopId"), "验证shopId");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_BindMobileWithWeiXin_002() {
		Logger.start(true,"不输入loginSession失败");
		try {
//			UserCreateBean u = DGUserCallService.initUsercreateBean();
			String mobile=TestDataManager.getPhoneNum();
//			//新用户授权联登 等于注册
//			bindmobilewithweixinBean.setIv(TestDataManager.getUTF8Base64(DGUserCallService.IV));
////			wxauthloginBean.setIv(DGUserCallService.IV);
//			WxLoginSession wxLoginSession=new WxLoginSession();
//			wxLoginSession.setOpenId(u.getOpenId());
//			wxLoginSession.setSessionKey(TestDataManager.getUTF8Base64(DGUserCallService.SESSIONKEY));
//			wxLoginSession.setUnionId(u.getUnionId());
//			String loginSession = DGUserCallService.encryptWxLoginSession(wxLoginSession);
//			bindmobilewithweixinBean.setLoginSession(loginSession);
			//加密组装encryptedData
			WxGetPhoneNumber WxGetPhoneNumber=new WxGetPhoneNumber();
			WxGetPhoneNumber.setCountryCode("86");
			WxGetPhoneNumber.setPhoneNumber(mobile);
			WxGetPhoneNumber.setPurePhoneNumber("86"+mobile);
			String encryptedData=DGUserCallService.encryptWxEncryptedData(FormatUtil.beanToGSONString(WxGetPhoneNumber), DGUserCallService.IV, DGUserCallService.SESSIONKEY);

			bindmobilewithweixinBean.setEncryptedData(encryptedData);
			bindmobilewithweixinBean.setShopId(1);
			bindmobilewithweixinBean.setUserId(1);
			bindmobilewithweixinCall.setData(bindmobilewithweixinBean);
			bindmobilewithweixinCall.callService();			
			Logger.verifyEquals("false", bindmobilewithweixinCall.getString("success"), "验证success");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_BindMobileWithWeiXin_003() {
		Logger.start(true,"不输入userId失败");
		try {
			UserCreateBean u = DGUserCallService.initUsercreateBean();
			String mobile=TestDataManager.getPhoneNum();
//			//新用户授权联登 等于注册
//			bindmobilewithweixinBean.setIv(TestDataManager.getUTF8Base64(DGUserCallService.IV));
			bindmobilewithweixinBean.setIv(DGUserCallService.IV);
			WxLoginSession wxLoginSession=new WxLoginSession();
//			wxLoginSession.setOpenId(u.getOpenId());
//			wxLoginSession.setSessionKey(TestDataManager.getUTF8Base64(DGUserCallService.SESSIONKEY));
//			wxLoginSession.setUnionId(u.getUnionId());
			String loginSession = DGUserCallService.encryptWxLoginSession(wxLoginSession);
			bindmobilewithweixinBean.setLoginSession(loginSession);
			//加密组装encryptedData
			WxGetPhoneNumber WxGetPhoneNumber=new WxGetPhoneNumber();
			WxGetPhoneNumber.setCountryCode("86");
			WxGetPhoneNumber.setPhoneNumber(mobile);
			WxGetPhoneNumber.setPurePhoneNumber("86"+mobile);
			String encryptedData=DGUserCallService.encryptWxEncryptedData(FormatUtil.beanToGSONString(WxGetPhoneNumber), DGUserCallService.IV, DGUserCallService.SESSIONKEY);

			bindmobilewithweixinBean.setEncryptedData(encryptedData);
			bindmobilewithweixinBean.setShopId(1);
//			bindmobilewithweixinBean.setUserId(1);
			bindmobilewithweixinCall.setData(bindmobilewithweixinBean);
			bindmobilewithweixinCall.callService();			
			Logger.verifyEquals("false", bindmobilewithweixinCall.getString("success"), "验证success");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_BindMobileWithWeiXin_004() {
		Logger.start(true,"不输入shopId失败");
		try {
			UserCreateBean u = DGUserCallService.initUsercreateBean();
			String mobile=TestDataManager.getPhoneNum();
//			//新用户授权联登 等于注册
//			bindmobilewithweixinBean.setIv(TestDataManager.getUTF8Base64(DGUserCallService.IV));
			bindmobilewithweixinBean.setIv(DGUserCallService.IV);
			WxLoginSession wxLoginSession=new WxLoginSession();
//			wxLoginSession.setOpenId(u.getOpenId());
//			wxLoginSession.setSessionKey(TestDataManager.getUTF8Base64(DGUserCallService.SESSIONKEY));
//			wxLoginSession.setUnionId(u.getUnionId());
			String loginSession = DGUserCallService.encryptWxLoginSession(wxLoginSession);
			bindmobilewithweixinBean.setLoginSession(loginSession);
			//加密组装encryptedData
			WxGetPhoneNumber WxGetPhoneNumber=new WxGetPhoneNumber();
			WxGetPhoneNumber.setCountryCode("86");
			WxGetPhoneNumber.setPhoneNumber(mobile);
			WxGetPhoneNumber.setPurePhoneNumber("86"+mobile);
			String encryptedData=DGUserCallService.encryptWxEncryptedData(FormatUtil.beanToGSONString(WxGetPhoneNumber), DGUserCallService.IV, DGUserCallService.SESSIONKEY);

			bindmobilewithweixinBean.setEncryptedData(encryptedData);
//			bindmobilewithweixinBean.setShopId(1);
			bindmobilewithweixinBean.setUserId(1);
			bindmobilewithweixinCall.setData(bindmobilewithweixinBean);
			bindmobilewithweixinCall.callService();			
			Logger.verifyEquals("false", bindmobilewithweixinCall.getString("success"), "验证success");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_BindMobileWithWeiXin_005() {
		Logger.start(true,"不输入encryptedData失败");
		try {
			UserCreateBean u = DGUserCallService.initUsercreateBean();
			String mobile=TestDataManager.getPhoneNum();
//			//新用户授权联登 等于注册
//			bindmobilewithweixinBean.setIv(TestDataManager.getUTF8Base64(DGUserCallService.IV));
			bindmobilewithweixinBean.setIv(DGUserCallService.IV);
			WxLoginSession wxLoginSession=new WxLoginSession();
//			wxLoginSession.setOpenId(u.getOpenId());
//			wxLoginSession.setSessionKey(TestDataManager.getUTF8Base64(DGUserCallService.SESSIONKEY));
//			wxLoginSession.setUnionId(u.getUnionId());
			String loginSession = DGUserCallService.encryptWxLoginSession(wxLoginSession);
			bindmobilewithweixinBean.setLoginSession(loginSession);
			//加密组装encryptedData
			WxGetPhoneNumber WxGetPhoneNumber=new WxGetPhoneNumber();
			WxGetPhoneNumber.setCountryCode("86");
			WxGetPhoneNumber.setPhoneNumber("86"+mobile);
			WxGetPhoneNumber.setPurePhoneNumber(mobile);
			String encryptedData=DGUserCallService.encryptWxEncryptedData(FormatUtil.beanToGSONString(WxGetPhoneNumber), DGUserCallService.IV, DGUserCallService.SESSIONKEY);

//			bindmobilewithweixinBean.setEncryptedData(encryptedData);
			bindmobilewithweixinBean.setShopId(1);
			bindmobilewithweixinBean.setUserId(1);
			bindmobilewithweixinCall.setData(bindmobilewithweixinBean);
			bindmobilewithweixinCall.callService();			
			Logger.verifyEquals("false", bindmobilewithweixinCall.getString("success"), "验证success");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_BindMobileWithWeiXin_006() {
		Logger.start(true,"不输入iv失败");
		try {
			UserCreateBean u = DGUserCallService.initUsercreateBean();
			String mobile=TestDataManager.getPhoneNum();
//			//新用户授权联登 等于注册
//			bindmobilewithweixinBean.setIv(TestDataManager.getUTF8Base64(DGUserCallService.IV));
////			wxauthloginBean.setIv(DGUserCallService.IV);
			WxLoginSession wxLoginSession=new WxLoginSession();
//			wxLoginSession.setOpenId(u.getOpenId());
//			wxLoginSession.setSessionKey(TestDataManager.getUTF8Base64(DGUserCallService.SESSIONKEY));
//			wxLoginSession.setUnionId(u.getUnionId());
			String loginSession = DGUserCallService.encryptWxLoginSession(wxLoginSession);
			bindmobilewithweixinBean.setLoginSession(loginSession);
			//加密组装encryptedData
			WxGetPhoneNumber WxGetPhoneNumber=new WxGetPhoneNumber();
			WxGetPhoneNumber.setCountryCode("86");
			WxGetPhoneNumber.setPhoneNumber("86"+mobile);
			WxGetPhoneNumber.setPurePhoneNumber(mobile);
			String encryptedData=DGUserCallService.encryptWxEncryptedData(FormatUtil.beanToGSONString(WxGetPhoneNumber), DGUserCallService.IV, DGUserCallService.SESSIONKEY);

			bindmobilewithweixinBean.setEncryptedData(encryptedData);
			bindmobilewithweixinBean.setShopId(1);
			bindmobilewithweixinBean.setUserId(1);
			bindmobilewithweixinBean.setIv(null);
			bindmobilewithweixinCall.setData(bindmobilewithweixinBean);
			bindmobilewithweixinCall.callService();			
			Logger.verifyEquals("false", bindmobilewithweixinCall.getString("success"), "验证success");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_BindMobileWithWeiXin_007() {
		Logger.start(true,"同一个shopId绑定同一个手机号多次-20200526返回这个手机号第一次绑定的用户信息");
		try {
			UserCreateBean u = DGUserCallService.initUsercreateBean();
			int userId = DGUserCallService.UserCreateCall(u);
			Integer shopId = GodmchManageCallService.CreateSellerMch();
			CreateMemberBean createMem = GodMemberService.initCreateMemberBean(shopId,userId,u.getOpenId());
			GodMemberService.creatememberCall(createMem);
			String mobile=TestDataManager.getPhoneNum();
			//新用户授权联登 等于注册
			bindmobilewithweixinBean.setIv(TestDataManager.getUTF8Base64(DGUserCallService.IV));
//			wxauthloginBean.setIv(DGUserCallService.IV);
			WxLoginSession wxLoginSession=new WxLoginSession();
			wxLoginSession.setOpenId(u.getOpenId());
			wxLoginSession.setSessionKey(TestDataManager.getUTF8Base64(DGUserCallService.SESSIONKEY));
			wxLoginSession.setUnionId(u.getUnionId());
			String loginSession = DGUserCallService.encryptWxLoginSession(wxLoginSession);
			bindmobilewithweixinBean.setLoginSession(loginSession);
			//加密组装encryptedData
			WxGetPhoneNumber WxGetPhoneNumber=new WxGetPhoneNumber();
			WxGetPhoneNumber.setCountryCode("86");
			WxGetPhoneNumber.setPhoneNumber("86"+mobile);
			WxGetPhoneNumber.setPurePhoneNumber(mobile);
			String encryptedData=DGUserCallService.encryptWxEncryptedData(FormatUtil.beanToGSONString(WxGetPhoneNumber), DGUserCallService.IV, DGUserCallService.SESSIONKEY);

			bindmobilewithweixinBean.setEncryptedData(encryptedData);
			bindmobilewithweixinBean.setShopId(shopId);
			bindmobilewithweixinBean.setUserId(userId);
			bindmobilewithweixinCall.setData(bindmobilewithweixinBean);
			bindmobilewithweixinCall.callService();			
			Logger.verifyEquals("true", bindmobilewithweixinCall.getString("success"), "验证success");
			String u1=bindmobilewithweixinCall.getString("userId");
			DGUserWapper DGUserWapper=new DGUserWapper();
			Logger.debug("u1:"+FormatUtil.beanToGSONString(DGUserWapper.selectDGUserInfo(userId).get(0)));
			//2个用户绑定同一个手机号失败
			UserCreateBean u2 = DGUserCallService.initUsercreateBean();
			int userId2 = DGUserCallService.UserCreateCall(u2);
			
			WxLoginSession wxLoginSession2=new WxLoginSession();
			wxLoginSession2.setOpenId(u2.getOpenId());
			wxLoginSession2.setSessionKey(TestDataManager.getUTF8Base64(DGUserCallService.SESSIONKEY));
			wxLoginSession2.setUnionId(u2.getUnionId());
			String loginSession2 = DGUserCallService.encryptWxLoginSession(wxLoginSession2);
			bindmobilewithweixinBean.setLoginSession(loginSession2);
			
			WxGetPhoneNumber WxGetPhoneNumber2=new WxGetPhoneNumber();
			WxGetPhoneNumber2.setCountryCode("86");
			WxGetPhoneNumber2.setPhoneNumber("86"+mobile);
			WxGetPhoneNumber2.setPurePhoneNumber(mobile);
			String encryptedData2=DGUserCallService.encryptWxEncryptedData(FormatUtil.beanToGSONString(WxGetPhoneNumber), DGUserCallService.IV, DGUserCallService.SESSIONKEY);

			bindmobilewithweixinBean.setEncryptedData(encryptedData2);
			bindmobilewithweixinBean.setUserId(userId2);
			bindmobilewithweixinCall.callService();			
			Logger.verifyEquals("true", bindmobilewithweixinCall.getString("success"), "验证success");
			Logger.debug("u2:"+FormatUtil.beanToGSONString(DGUserWapper.selectDGUserInfo(userId2).get(0)));
			Logger.verifyEquals(u1, bindmobilewithweixinCall.getString("userId"), "验证是第一个用户");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_BindMobileWithWeiXin_008() {
		Logger.start(true,"同一个shopId绑定同一个userId多次--相当于换手机");
		try {
			UserCreateBean u = DGUserCallService.initUsercreateBean();
			int userId = DGUserCallService.UserCreateCall(u);
			Integer shopId = GodmchManageCallService.CreateSellerMch();
			CreateMemberBean createMem = GodMemberService.initCreateMemberBean(shopId,userId,u.getOpenId());
			GodMemberService.creatememberCall(createMem);
			String mobile=TestDataManager.getPhoneNum();
			//新用户授权联登 等于注册
			bindmobilewithweixinBean.setIv(TestDataManager.getUTF8Base64(DGUserCallService.IV));
//			wxauthloginBean.setIv(DGUserCallService.IV);
			WxLoginSession wxLoginSession=new WxLoginSession();
			wxLoginSession.setOpenId(u.getOpenId());
			wxLoginSession.setSessionKey(TestDataManager.getUTF8Base64(DGUserCallService.SESSIONKEY));
			wxLoginSession.setUnionId(u.getUnionId());
			String loginSession = DGUserCallService.encryptWxLoginSession(wxLoginSession);
			bindmobilewithweixinBean.setLoginSession(loginSession);
			//加密组装encryptedData
			WxGetPhoneNumber WxGetPhoneNumber=new WxGetPhoneNumber();
			WxGetPhoneNumber.setCountryCode("86");
			WxGetPhoneNumber.setPhoneNumber("86"+mobile);
			WxGetPhoneNumber.setPurePhoneNumber(mobile);
			String encryptedData=DGUserCallService.encryptWxEncryptedData(FormatUtil.beanToGSONString(WxGetPhoneNumber), DGUserCallService.IV, DGUserCallService.SESSIONKEY);

			bindmobilewithweixinBean.setEncryptedData(encryptedData);
			bindmobilewithweixinBean.setShopId(shopId);
			bindmobilewithweixinBean.setUserId(userId);
			bindmobilewithweixinCall.setData(bindmobilewithweixinBean);
			bindmobilewithweixinCall.callService();			
			Logger.verifyEquals("true", bindmobilewithweixinCall.getString("success"), "验证success");
			
//			MessageListBean MessageListBean = MqQueryCallService.initGoduserBindMobile(userId);
//			List <Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
//			if(joa.size()==0){
//				Thread.sleep(5000);
//				 joa = MqQueryCallService.GetMqMessage(MessageListBean);
//			}
//			joa.forEach(ele->{
//				Logger.debug(ele.toString());
//			});
//			Logger.verifyEquals(WxGetPhoneNumber.getPhoneNumber(), joa.get(0).get("mobile"), "验证mobile");
//			Logger.verifyEquals(userId, joa.get(0).get("userId"), "验证userId");
//			Logger.verifyEquals(shopId, joa.get(0).get("shopId"), "验证shopId");
//			UserCreateBean u2 = DGUserCallService.initUsercreateBean();
//			int userId2 = DGUserCallService.UserCreateCall(u2);
//			
//			WxLoginSession wxLoginSession2=new WxLoginSession();
//			wxLoginSession2.setOpenId(u2.getOpenId());
//			wxLoginSession2.setSessionKey(TestDataManager.getUTF8Base64(DGUserCallService.SESSIONKEY));
//			wxLoginSession2.setUnionId(u2.getUnionId());
//			String loginSession2 = DGUserCallService.encryptWxLoginSession(wxLoginSession2);
//			bindmobilewithweixinBean.setLoginSession(loginSession2);
			
			//1个用户重复成为会员失败
			String mobile2=TestDataManager.getPhoneNum();
			WxGetPhoneNumber WxGetPhoneNumber2=new WxGetPhoneNumber();
			WxGetPhoneNumber2.setCountryCode("86");
			WxGetPhoneNumber2.setPhoneNumber("86"+mobile2);
			WxGetPhoneNumber2.setPurePhoneNumber(mobile2);
			String encryptedData2=DGUserCallService.encryptWxEncryptedData(FormatUtil.beanToGSONString(WxGetPhoneNumber), DGUserCallService.IV, DGUserCallService.SESSIONKEY);

			bindmobilewithweixinBean.setEncryptedData(encryptedData2);
			bindmobilewithweixinCall.callService();			
			Logger.verifyEquals("true", bindmobilewithweixinCall.getString("success"), "验证success");
//			 MessageListBean = MqQueryCallService.initGoduserBindMobile(userId);
//			 joa = MqQueryCallService.GetMqMessage(MessageListBean);
//			if(joa.size()==0){
//				Thread.sleep(5000);
//				 joa = MqQueryCallService.GetMqMessage(MessageListBean);
//			}
//			joa.forEach(ele->{
//				Logger.debug(ele.toString());
//			});
//			Logger.verifyEquals(WxGetPhoneNumber.getPhoneNumber(), joa.get(0).get("mobile"), "验证mobile");
//			Logger.verifyEquals(userId, joa.get(0).get("userId"), "验证userId");
//			Logger.verifyEquals(shopId, joa.get(0).get("shopId"), "验证shopId");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	//			bindmobilewithverifycodeBean.setClientIp(TestDataManager.getRandomIp().toLowerCase());
//	bindmobilewithverifycodeBean.setDeviceId(TestDataManager.getRandomUUID().toString());
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_BindMobileWithWeiXin_009() {
		Logger.start(true,"买家微信绑定手机号成功-传入clientIp-deviceId");
		try {
			UserCreateBean u = DGUserCallService.initUsercreateBean();
			int userId = DGUserCallService.UserCreateCall(u);
			Integer shopId = GodmchManageCallService.CreateSellerMch();
			CreateMemberBean createMem = GodMemberService.initCreateMemberBean(shopId,userId,u.getOpenId());
			GodMemberService.creatememberCall(createMem);
			
			String mobile=TestDataManager.getPhoneNum();
			//新用户授权联登 等于注册
			bindmobilewithweixinBean.setIv(TestDataManager.getUTF8Base64(DGUserCallService.IV));
//			wxauthloginBean.setIv(DGUserCallService.IV);
			WxLoginSession wxLoginSession=new WxLoginSession();
			wxLoginSession.setOpenId(u.getOpenId());
			wxLoginSession.setSessionKey(TestDataManager.getUTF8Base64(DGUserCallService.SESSIONKEY));
			wxLoginSession.setUnionId(u.getUnionId());
			String loginSession = DGUserCallService.encryptWxLoginSession(wxLoginSession);
			bindmobilewithweixinBean.setLoginSession(loginSession);
			//加密组装encryptedData
			WxGetPhoneNumber WxGetPhoneNumber=new WxGetPhoneNumber();
			WxGetPhoneNumber.setCountryCode("86");
			WxGetPhoneNumber.setPhoneNumber("86"+mobile);
			WxGetPhoneNumber.setPurePhoneNumber(mobile);
			String encryptedData=DGUserCallService.encryptWxEncryptedData(FormatUtil.beanToGSONString(WxGetPhoneNumber), DGUserCallService.IV, DGUserCallService.SESSIONKEY);

			bindmobilewithweixinBean.setEncryptedData(encryptedData);
			bindmobilewithweixinBean.setShopId(shopId);
			bindmobilewithweixinBean.setUserId(userId);
			bindmobilewithweixinCall.setData(bindmobilewithweixinBean);
			bindmobilewithweixinCall.callService();			
			Logger.verifyEquals("true", bindmobilewithweixinCall.getString("success"), "验证success");
			//20200526 现在直接调用不绑定
//			MessageListBean MessageListBean = MqQueryCallService.initGoduserBindMobile(userId);
//			List <Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
//			if(joa.size()==0){
//				Thread.sleep(5000);
//				 joa = MqQueryCallService.GetMqMessage(MessageListBean);
//			}
//			joa.forEach(ele->{
//				Logger.debug(ele.toString());
//			});
//			Logger.verifyEquals(WxGetPhoneNumber.getPhoneNumber(), joa.get(0).get("mobile"), "验证mobile");
//			Logger.verifyEquals(userId, joa.get(0).get("userId"), "验证userId");
//			Logger.verifyEquals(shopId, joa.get(0).get("shopId"), "验证shopId");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}